<?php
/**
 *
 * User: wufeng
 * Date: 2020/06/08
 */

namespace app\admin\command;
use app\api\controller\Qywx;
use app\models\StudentModel;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;

class FollowUp extends Command
{
	/**
	 * User: Truman
	 * Date: 2020/08/11
	 *
	 * @param $val
	 * @param $output
	 */
	public function followUpStatus($val, $output)
	{
		$qywx = new Qywx();
		//第一步：获取access_token
		$access_token = $qywx->getAccessToken();
		//第二步：获取所有部门
		$departmentList = $qywx->getDepartmentList($access_token);
		//第三步：获取公司下的所有员工
		$userList = $qywx->getUserList($access_token,$departmentList[0]['id']);
		$val = $val.''.date('H:i:s');
		$course_consultants = (new StudentModel())->where(['next_follow_up_timestamp'=>strtotime($val)])->column('course_consultant');
		$where = [];
		$where['follow_up']  = 36;
		$where['is_audition']  = ['in','0,1'];
		$where['status'] = 1;
		foreach ($userList as $value){
			if(in_array($value['name'],$course_consultants,type)){

			}
		}

		$output->writeln('执行完成：'.date('Y-m-d h:i:s'));
	}

	/**
	 * User: Truman
	 * Date: 2020/08/11
	 *
	 */
	protected function configure()
	{
		$this->setName('FollowUp')
			->addOption('function', 'f', Option::VALUE_REQUIRED, 'function name', null)
			->addOption('value', 'a', Option::VALUE_REQUIRED, 'value name', null)
			->setDescription('Here is the PTS ');
	}

	/**
	 * User: Truman
	 * Date: 2020/08/11
	 *
	 * @param Input $input
	 * @param Output $output
	 * @return int|void|null
	 */
	protected function execute(Input $input, Output $output)
	{
		$functionName = $input->getOption('function') ?: '';
		$value = $input->getOption('value') ?: '';
		$this->{$functionName}($value, $output);
		$output->writeln('执行完成：'.date('Y-m-d h:i:s'));
	}
}